import { App, Configuration, Inject } from '@midwayjs/decorator';
import { ILifeCycle, IMidwayContainer } from '@midwayjs/core';
import { Application, Context } from 'egg';
import { join } from 'path';
import * as orm from '@midwayjs/orm';

@Configuration({
  importConfigs: [join(__dirname, './config')],
  conflictCheck: true,
  imports: [
    orm                             // 加载 orm 组件
  ],
})

export class ContainerLifeCycle implements ILifeCycle {
  @App()
  app: Application;

  @Inject()
  ctx:Context;

  async onReady(container: IMidwayContainer): Promise<void> {
    // 建立数据库连接
    //this.app.model.User.sync({force:true})

    //this.ctx.model.User.force()
    //this.app.model.sync({force:true})
    console.log('AA')
  }
}
